package com.sinux.generality.provider.demo.init;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.sinux.generality.provider.demo.constants.Sets;
import com.sinux.generality.provider.demo.tool.MyHttpUtil;
import com.sinux.generality.provider.demo.tool.OpenUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.lang.reflect.Method;

@Component
@Order(100)
public class TaskInit {
    @Value("${proxyIp}")
    private String proxyIp;
    @Value("${proxyPort}")
    private int proxyPort;
    @Value("${tokenApi}")
    private String tokenApi;
    private static Logger logger = LoggerFactory.getLogger(TaskInit.class);
    @PostConstruct()
    public void init() {
        Class queryWrapperClass = QueryWrapper.class;
        Method[] methods = queryWrapperClass.getMethods();
        for(Method m:methods){
            Sets.queryWrapperMap.put(m.getName(), m);
        }

        OpenUtil.tokenApi = this.tokenApi;
        MyHttpUtil.proxyIp = this.proxyIp;
        MyHttpUtil.proxyPort = this.proxyPort;
    }
}
